www.gusucode.com > 星梦奇缘交友网 1 > 星梦奇缘交友网 1.0源码程序/love/admin/ArtType.asp

    <!--#include file=../conn.asp-->
<!-- #include file="inc/const.asp" -->
<%Head()
	dim admin_flag
	admin_flag=",22,"
	if not master or instr(","&session("flag")&",",admin_flag)=0 then
		Errmsg=ErrMsg + "<BR><li>本页面为管理员专用,请<a href=../"&LoginUrl&" target=_top>登录</a>后进入。<br><li>您没有管理本页面的权限。"
		Call Ms_error()
	End If
		dim pid
		pid=trim(request("pid"))
		Main(1)
		if request("action")="list" then
		call list()
		elseif request("action")="add" then
		call add()
		elseif request("action")="savenew" then
		call savenew()
		elseif request("action")="up" then
		call up()
		elseif request("action")="down" then
		call down()
		elseif request("action")="edit" then
		call edit()
		elseif request("action")="saveedit" then
		call saveedit()
		elseif request("action")="ToSet" then
		call ToSet()
		end if
		Main(0)
		Footer()

sub main(Str)
if Str=1 then%>
<table width="95%" border="0" cellspacing="1" cellpadding="3"  align=center class="tableBorder">
<tr> 
<th height="23" colspan="8" class="tableHeaderText">文章类别管理中心</th>
</tr>
<tr>
    <td height="25" colspan="8" align="center" class="forumrow">文章类别添加删除、此操作不可逆。</td>
</tr>
<tr>
<td height="25" colspan="1" class="forumrow">快捷方式
</td>
<td height="25" colspan="7" class="forumrow"><a href=?action=list&t=1>所有类别</a>
</td>
</tr>
<%
	Else
%>
</table>
<p></p>
<%end if
end sub

sub list()''列出类别
strFileName="ArtType.asp?action="&Request("action") & "&t="&request("t")&""
call tumppages()
dim sqlt
sqlt= " id,Boardname,Readme,Orders,Layer,Pid "
%>
<tr>
<th colspan=8 align=left height=23>类别列表</th>
</tr>
<tr>
<td height="25" colspan="8" class="forumrow">现在的位置:<a href=?ArtType.asp?action=list&t=1>类别首页</a><%if pid<>"" then%>
      <%dim Pnext,rsLine,parr
	  Set rs = Server.CreateObject("ADODB.Recordset")
	sql="select Pnext from Ms_Arttype where ID="&pid&""
  rs.open sql,conn,1,1
  if not rs.eof then
  Pnext=rs(0)
  end if
  rs.close
  if Pnext<>"" then
  Set rsLine = Server.CreateObject("ADODB.Recordset")
	sql="select Boardname,ID from Ms_Arttype where ID in("&Pnext&") order by ID asc"
  rsLine.open sql,conn,1,1
  if not rsLine.eof then
  do while not rsline.eof
  parr=parr&"&gt;&gt;&gt; <a href=ArtType.asp?action=list&t=1&pid="&rsLine(1)&">"&rsLine(0)&"</a>"
  rsline.movenext
  loop
  end if
  rsLine.close
  end if
  end if
	response.Write(parr)%>
</td>
</tr>
<FORM METHOD=POST ACTION="?action=ToSet">
<tr align=center height=23>
<td class=forumRowHighlight width="20%"><B>文章类别</B></td>
<td class=forumRowHighlight width="8%"><B>记录ID</B></td>
<td class=forumRowHighlight width="40%"><B>类别简介</B></td>
<td class=forumRowHighlight width="10%"><B>排序</B></td>
<td class=forumRowHighlight width="8%"><B>层级</B></td>
<td class=forumRowHighlight width="6%"><B>修改</B></td>
<td class=forumRowHighlight><B>操作</B></td>
</tr>
<%set rs=server.createobject("adodb.recordset")
Select Case Request("t")
	Case 1
	if pid<>"" then 
		Sql = "SELECT " & sqlt & " from Ms_ArtType where Pid="&pid&" and ID<>"&pid&" ORDER BY Orders aSC"
		else
		Sql = "SELECT " & sqlt & " from Ms_ArtType where Layer=1 ORDER BY Orders aSC"
	end if
	case else
		Response.Write "<tr><td colspan=8 class=forumrow>错误的参数。</td></tr>"
		Response.End
	End Select
rs.Open sql,conn,1,1
if not (rs.eof and rs.bof) then
call rspages()
do while not rs.eof and page_count<Cint(MaxPerPage)%>
<tr>
<td class=forumrow align="center"><a href=?action=list&t=1&Pid=<%=rs(0)%>><%=rs(1)%></a></td>
<td class=forumrow align="center"><%=rs(0)%></td>
<td class=forumrow><%=rs(2)%></td>
<td class=forumrow align=center><%=rs(3)%> <%if rs(3)=1 then
response.Write("↑")
else%><a href=?action=up&id=<%=rs(0)%>&orders=<%=rs(3)%>&Pid=<%=Pid%>><font color="#FF0000">↑</font></a><%end if%> <a href=?action=down&id=<%=rs(0)%>&orders=<%=rs(3)%>&Pid=<%=Pid%>><font color=blue>↓</font></a></td>
<td class=forumrow align=center><%=rs(4)%>
</td>
<td class=forumrow align=center><a href=?action=edit&id=<%=rs(0)%>>修改</a></td>
<td class=forumrow align=center><input type="checkbox" name="id" value="<%=rs(0)%>"></td>
</tr>
<%page_count=page_count+1
  rs.movenext
  loop
  else
  response.Write("<tr align=center><td height=24 colspan=8 class=forumrow>暂无记录</td></tr>")
  end if
  
 if totalrec>0 then %>
    <tr align="center"> 
      <td height="24" colspan="8" class=forumrow> <%
		  	call showpage(strFileName)
		  %></td>
    </tr>
	<%end if%>
<tr align="center"> 
      <td height="24" colspan="8" class=forumrow><input type="radio" name="paction" value=1>删除记录
	  
全部选定<input type=checkbox value="on" name="chkall" onclick="CheckAll(this.form)"></td>
    </tr>
	<tr align="center"> 
      <td height="24" colspan="8" class=forumRowHighlight><input type=submit name=submit value="执行操作"  onclick="{if(confirm('确定执行操作吗?')){return true;}return false;}"> <input type=button name=action onclick="location.href='?action=add&Pid=<%=pid%>'" value="添加类别"></td>
    </tr>
</form>
<%end sub

sub add()
dim classid,layernum,pnexts,MaxSortID,SortID,Orders%>
<form name="form" method="post" action="?action=savenew">
    <tr align="center"> 
      <th height="25" colspan="8">添 加 类 别</th>
    </tr>
    <%Set rs = Server.CreateObject("ADODB.Recordset")
  sql="select top 1 ID,layer from Ms_Arttype order by ID desc"
  rs.open sql,conn,1,1
  if not rs.eof then
  classid=rs(0)
  end if
  rs.close
  
  if pid<>"" then
  Set rs = Server.CreateObject("ADODB.Recordset")
  sql="select layer,pnext from Ms_Arttype where ID="&pid&""
  rs.open sql,conn,1,1
  if not rs.eof then
  layernum=rs("layer")
  pnexts=rs("pnext")
  end if
  rs.close
    Set rs = Server.CreateObject("ADODB.Recordset")
  sql="select top 1 Orders from Ms_Arttype where ID="&pid&" order by orders desc"
  rs.open sql,conn,1,1
  if not rs.eof then
  Orders=rs(Orders)
  end if
  rs.close
  else
  layernum=0
  Orders=1
  end if
  
  set rs = conn.execute("select Max(ID) From Ms_Arttype")
	MaxSortID=rs(0)
	if isnull(MaxSortID) then
		MaxSortID=0
	end if
	rs.close
	SortID=MaxSortID+1
  %>
    <tr> 
      <td width="44%" height="12" align="right" class=Forumrow>文章类别:</td>
      <td width="56%" height="12" class=Forumrow> <input name="Boardname" type="text" maxlength="50">
        * (不要超过50字)
        <%if pid="" then
		response.Write("<font color=red>属于一级分类</font>")
		end if%> <input name="pid" type="hidden" value=<%if pid<>"" then%><%=pid%><%else%><%=classid+1%><%end if%>> 
        <input name="layer" type="hidden" value=<%=layernum%>> 
		<input name="Orders" type="hidden" value=<%=Orders%>> 
        <input name="pnext" type="hidden" value="<%if pid<>"" then%><%=pnexts%>,<%else%><%=classid+1%>,<%end if%><%=SortID%>"> 
      </td>
    </tr>
	<tr>
	<td width="44%" height="12" align="right" class=Forumrow>类别说明:</td>
      <td width="56%" height="12" class=Forumrow><textarea name="Readme" cols="40" rows="4"></textarea></td>
	  </tr>
    <tr> 
      <td height="25" colspan="2" align="center" class=Forumrow> <input type="submit" name="Submit" value="添  加"></td>
    </tr>
  </form>
<%end sub

sub savenew()
dim Boardname,TID,pid,layer,pnext,Readme,Orders
Boardname=trim(request("Boardname"))
layer=trim(request("layer"))
pnext=trim(request("pnext"))
pid=trim(request("pid"))
Readme=trim(request("Readme"))
Orders=trim(request("Orders"))
if Boardname="" or strLength(Boardname)>100 then
   founderr=true
   ErrMsg=ErrMsg & "<br><li>文章类别不能为空长度不大于100个字符,请重新输入!</li>"
   end if
if pid<>"" and isnumeric(pid)=false then
   founderr=true
   errmsg=errmsg & "<br><li>参数错误,请重新输入!</li>"
   end if
   if founderr=true then Call Ms_error()
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select Boardname,pid,layer,pnext,Readme,Orders from Ms_Arttype where Boardname='"&Boardname&"' and pid="&pid&""
rs.open sql,conn,1,3
if rs.eof or rs.bof then
rs.addnew()
rs("Boardname")=Boardname
rs("pid")=pid
rs("Readme")=Readme
rs("layer")=(layer+1)
rs("pnext")=pnext
rs("Orders")=Orders
rs.update
rs.close
Ms_suc("<br><li>["&Boardname&"]文章类别已经建立!</li>")
else
   founderr=true
   errmsg=errmsg &"<br><li>["&Boardname&"]文章类别已经存在,请不要重复输入!</li>"
   exit sub
   Call Ms_error()
end if
end sub

sub up()''提升排序
dim id,orders,pid,uorders,dorders
id=trim(request("id"))
orders=trim(request("orders"))
pid=trim(request("pid"))
conn.execute("update Ms_Arttype set orders="&orders&" where orders="&(orders-1)&" and pid="&pid&"")
conn.execute("update Ms_Arttype set orders="&(orders-1)&" where id="&id&"")
Ms_suc("<br><li>您已成功提升排序</li>")
end sub

sub down()''降低排序
dim id,orders,pid,uorders,dorders
id=trim(request("id"))
orders=trim(request("orders"))
pid=trim(request("pid"))
conn.execute("update Ms_Arttype set orders="&orders&" where orders="&(orders+1)&" and pid="&pid&"")
conn.execute("update Ms_Arttype set orders="&orders+1&" where id="&id&"")
Ms_suc("<br><li>您已成功提升排序</li>")
end sub

sub edit()''修改
dim id
id=trim(request("id"))
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from Ms_Arttype where id="&id&""
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then%>
<form name="form" method="post" action="?action=saveedit">
    <tr align="center"> 
      <th height="25" colspan="8">修 改 类 别</th>
    </tr>
    <tr> 
      <td width="44%" height="12" align="right" class=Forumrow>文章类别:</td>
      <td width="56%" height="12" class=Forumrow> <input name="Boardname" type="text" maxlength="50" value="<%=rs("Boardname")%>">
        * (不要超过50字)
        <input name="id" type="hidden" value=<%=id%>> 
      </td>
    </tr>
	<tr>
	<td width="44%" height="12" align="right" class=Forumrow>类别说明:</td>
      <td width="56%" height="12" class=Forumrow><textarea name="Readme" cols="40" rows="4"><%=rs("Readme")%></textarea></td>
	  </tr>
    <tr> 
      <td height="25" colspan="2" align="center" class=Forumrow> <input type="submit" name="Submit" value="修 改"></td>
    </tr>
  </form>
<%end if
rs.close
end sub

sub saveedit()''保存修改
dim id,Boardname,Readme
id=trim(request("id"))
Boardname=trim(request("Boardname"))
Readme=trim(request("Readme"))
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select Readme,Boardname from Ms_Arttype where id="&id&""
rs.open sql,conn,1,3
if not (rs.eof and rs.bof) then
rs("Readme")=Readme
rs("Boardname")=Boardname
rs.update
rs.close
end if
Ms_suc("<br><li>您已保存成功</li>")
end sub

sub ToSet()
dim delid,FixID
delid=replace(request("id"),"'","")
delid=replace(delid,";","")
delid=replace(delid,"--","")
delid=replace(delid,")","")
fixid=replace(delid,",","")
fixid=Trim(replace(fixid," ",""))
If Not IsNumeric(fixid) Then
	Errmsg=Errmsg+"<br><li>错误的参数。"
	founderr=true
End If
if delid="" or isnull(delid) then
Errmsg=Errmsg+"<li>"+"请选择相关类。"
Founderr=true
end if
if founderr=true then call Ms_error()
conn.execute("delete from Ms_ArtType where ID in("&delid&")")
Ms_suc("<br><li>您成功删除了所选类别</li>")
end sub%>